package cn.chen.sparkproject

import org.apache.spark.{SparkConf, SparkContext}

object SortKeyTest {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("SortKeyTest")
    val sc = new SparkContext()

    val ar = Array(Tuple2(new SortKey(30, 35, 40), "1"),
      Tuple2(new SortKey(35, 30, 40), "2"),
      Tuple2(new SortKey(30, 38, 30), "3"))

    val rdd = sc.parallelize(ar)
    val sortedRDD = rdd.sortByKey(false)
    for(tuple <- sortedRDD.collect()){
      println(tuple._2)
    }
  }


}
